package com.yl.users.mapper

import com.baomidou.mybatisplus.core.mapper.BaseMapper
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.yl.users.entity.CompanyLinkDeptUser
import com.yl.users.entity.CompanyUser
import com.yl.users.pojo.vo.CompanyUserSelectVo
import org.apache.ibatis.annotations.Mapper
import org.apache.ibatis.annotations.Param

@Mapper
interface CompanyLinkDeptUserMapper : BaseMapper<CompanyLinkDeptUser> {

	/**
	 * 部门用户分页查询
	 */
	fun selectDeptUserPage(
		@Param("page") page: Page<CompanyUser>,
		@Param("vo") vo: CompanyUserSelectVo,
		@Param("deptId") deptId: Long
	): Page<CompanyUser>

	/**
	 * 部门用户列表
	 */
	fun selectDeptUserList(
		@Param("vo") vo: CompanyUserSelectVo,
		@Param("deptId") deptId: Long
	): MutableList<CompanyUser>

	/**
	 * 分院用户分页
	 */
	fun getSubCompanyUserPage(
		@Param("page") page: Page<CompanyUser>,
		@Param("vo") vo: CompanyUserSelectVo,
		@Param("subCompanyId") subCompanyId: Long
	): Page<CompanyUser>

	/**
	 * 分院用户列表
	 */
	fun getSubCompanyUserList(
		@Param("vo") vo: CompanyUserSelectVo,
		@Param("subCompanyId") subCompanyId: Long
	): MutableList<CompanyUser>

	/**
	 * 查询部门下（包含子部门的用户列表）
	 */
	fun selectUserByDeptId(@Param("page")page : Page<CompanyUser>,
	                       @Param("vo")vo : CompanyUserSelectVo,
	                       @Param("deptId")deptId : Long,
	                       @Param("companyId")companyId : Long
	):Page<CompanyUser>

	/**
	 * 分院下，是否还有部门与用户关联
	 */
	fun subCompanyHaveUserInDept(@Param("userId")userId:Long,@Param("subCompanyId")subCompanyId: Long):Int
}
